package com.zut.yunxi.yunxi.service.impl;

import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zut.yunxi.yunxi.dao.RefundDao;
import com.zut.yunxi.yunxi.entity.RefundEntity;
import com.zut.yunxi.yunxi.service.RefundService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;


@Service("refundService")
public class RefundServiceImpl extends ServiceImpl<RefundDao, RefundEntity> implements RefundService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        String id = (String) params.get("id");
        QueryWrapper<RefundEntity> queryWrapper=new QueryWrapper<RefundEntity>();
        if(StringUtils.isNotBlank(id))
            queryWrapper.eq("user_id",id);
        if(StringUtils.isNotBlank(key))
        {
            queryWrapper.eq("id",key).or().like("order_id",key);
        }
        IPage<RefundEntity> page = this.page(
                new Query<RefundEntity>().getPage(params),
                queryWrapper

        );
        return new PageUtils(page);
    }

}